package com.apimarket.dao;

import com.apimarket.entity.Publish;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * xuyang
 */
public interface PublishMapper {
    @Select({
            "<script>",
            "select * from publish",
            "where 1=1",
            "<when test = 'id != null'> and id = #{id} </when>",
            "</script>"
    })
    List<Publish> queryList(Publish entity);

    @Insert("INSERT INTO `publish`(`id`, `set_id`, `user_id`, `content`, `pic_urls`, `state`, `examine_id`) VALUES (#{id},#{setId},#{userId},#{content},#{picUrls},#{state},#{examineId})")
    int insert(Publish entity);

    @Update("UPDATE `publish` SET `id` = #{id}, `set_id` = #{setId}, `user_id` = #{userId}, `content` = #{content}, `pic_urls` = #{picUrls}, `state` =#{state}, `examine_id` = #{examineId} WHERE `id` = #{id}")
    int update(Publish entity);

    @Delete("delete from publish where id = #{id}")
    int delete(Integer id);
}
